<?php
namespace app\index\model;
use think\Model;
use think\Db;
use think\Cache;

class Specific extends Model
{
	public function getWhereData($param)
	{
		return self::field('s_id,s_name,type_id,s_free')
						->where('s_show', 1)
						->where('nav_id', $param['nav_id'])
						->when($param['type_id'], function($query) use ($param){
							$query->where('type_id', $param['type_id']);
						})
						->order('s_sort desc,s_id asc')
						->select();
	}

	public function getOneData($id)
	{
		return self::field('s_id,s_name,type_id,s_free')
						->where('s_id', $id)
						->where('s_show', 1)
						->find();
	}

	public function getSIds($value, $field)
	{
		return self::where($field, $value)
						->where('s_show', 1)
						->order('s_sort desc,s_id asc')
						->column('s_id');
	}

	public function getWhereTypeData($param)
	{
		return  self::field('s_id,s_name')
					->when($param['type_id'], function($query) use ($param){
						$query->where('type_id', $param['type_id']);
					})
					->order('s_sort desc')->select();
	}
}